package com.leo.entity;

import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.dsl.components.LiftComponent;
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.entity.EntityFactory;
import com.almasb.fxgl.entity.SpawnData;
import com.almasb.fxgl.entity.Spawns;
import com.leo.component.MapComponent;
import javafx.util.Duration;

/**
 * @Author: wangss
 * @CreateTime: 2023-06-19  21:58
 * @Description: TODO
 */
public class MapEntityFactory implements EntityFactory {

    @Spawns("rect")
    public Entity createRect(SpawnData spawnData) {
        LiftComponent liftComponent = new LiftComponent();
        liftComponent.setGoingRight(false);
        liftComponent.xAxisDistanceDuration(200, Duration.seconds(2));
        return FXGL.entityBuilder(spawnData)
                .with(new MapComponent())
                .with(liftComponent)
                .build();
    }

    @Spawns("mountain")
    public Entity createMountain(SpawnData spawnData) {
        return FXGL.entityBuilder(spawnData)
                .neverUpdated()
                .build();
    }
}
